import React, { useState, useEffect } from 'react';
import { Form, Card, Button, Progress, Row, Col, Tabs, Tag, Menu, Dropdown, Icon, message, Spin } from 'antd';
import { history } from 'umi'
import { connect } from 'umi';
import moment from 'moment/moment';
import pageTabUtil from '@/utils/pageTabUtil';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import { StartTaskModal, RevalAplModal, TaskDetailBox, AssessmentModal, ApplyAssessmentModal } from '../../components';
import ReRateApplyModal from '../../components/ScoreModal/ReRateApplyModal';
import RatingFormModal from '../../components/ScoreModal/RatingFormModal';
import RatingMgtModal from '../../components/ScoreModal/RatingMgtModal';
import { modalTypes as scoreModalTypes } from '../../components/ScoreModal/modalTypes';
import SubTask from './components/Subtask/Subtask';
import ScoreRec from './components/ScoreRec/ScoreRec';
import EstimateRec from './components/EstimateRec/EstimateRec';
import DetailInfo from './components/DetailInfo/DetailInfo';

// 变更记录
import ChangeRec from './components/ChangeRec/ChangeRec';
// 操作记录
import OperationRec from './components/OperationRec/OperationRec';
// 任务详情-任务环节
import TaskLink from './components/TaskLink/TaskLink';
// 任务详情-执行周期
import ExecutionCycle from './components/ExecutionCycle/ExecutionCycle';
import { showReScoreModal } from '../MyExecute/utils';
import {
    getTaskInfo,
    getPressActionTaskInfo,
    getCancelInfo,
    getRestartInfo,
    getSendBackInfo,
    checkOperate,
    getTurnDoingInfo,
    getProgressInfo,
    checkTurnFinish,
    getAuditInfo,
    getreestimationemployeelist,
    getEstimatedTaskList,
    getEstimationnotrequired,
    getEstimationlaunch
} from '../../services';
import {
    TimeFormat,
    TimeFormatHour,
    delayTimeFormat,
    getTaskDuration,
    getTaskStatus,
    getTaskPriority,
    getTaskSituation,
    getTaskFlag,
    ActionObj,
    TaskStatus,
    TaskAction,
    PageFromType,
    toNum,
    refreshTaskCount,
    TaskAuditType
} from '../../utils';
import {
    PressActionModal,
    ProgressActionModal,
    PauseActionModal,
    showPressModal,
    showUnRestartModal,
    showContinueModal,
    CancelNoActionModal,
    CancelActionModal,
    CancelDirectActionModal,
    TurnDoingFalseModal,
    TurnDoingTrueModal,
    TurnFinishActionModal,
    SendBackActionModal,
    TransferActionModal,
    DelayFormModal,
    AcceptanceActionModal,
    showAcceptanceYesModal,
    showAuditPassActionModal,
    AuditRefuseActionModal,
    ReEstimateActionModal
} from '../containers/MyTaskActionModal';
import {
    showTipBoxInfoModal,
    showTurnFinishExistsOnDoningSubInfoModal,
    showCantCheckInfoModal
} from '../containers/MyTaskInfoModal';
import styles from './MyExecuteDetail.less';

const { TabPane } = Tabs;

// 是否可以催办
const canPress = async taskId => {
    const res = await getPressActionTaskInfo(taskId);
    const { code, data, msg } = res;
    if (code !== 10000 || !data) {
        throw new Error(msg || '操作失败！');
    }
    const { auditNotPassFlag, sendBackFlag } = data;
    return [!(auditNotPassFlag || sendBackFlag), data];
};
// 是否可以审核
const canAudit = async (parentTaskId, actionType) => {
    if (parentTaskId) {
        const res = await getAuditInfo(parentTaskId);
        const { code, data, msg } = res;
        if (code !== 10000 || !data) {
            throw new Error(msg || '返回数据异常~~~');
        }
        const { taskAuditStatus } = data;
        // 通过操作时，父任务为非通过
        const passCon = actionType === TaskAuditType.PASS && taskAuditStatus !== TaskAuditType.PASS;
        // 不通过操作时，父任务未审核时
        const refuseCon = actionType === TaskAuditType.REFUSE && taskAuditStatus === TaskAuditType.INIT;
        if (passCon || refuseCon) {
            return [false, data];
        }
    }
    return [true];
};
const MyExecuteDetail = ({ form, location, user, dispatch }) => {
    const { query: urlQuery } = location;
    const [loading, setLoading] = useState(false);
    const [visible, setVisible] = useState(false);
    const [detailInfo, setDetailInfo] = useState({});
    const [showTab, setShowTab] = useState(urlQuery.activeKey || 'detailMsg');
    // 监控操作项完成后刷新页面
    const [refreshComp, setRefreshComp] = useState(0);
    // 发起任务弹窗显示与否
    const [startModalVisible, setStartModalVisible] = useState(false);
    // 发起任务弹窗参数
    const [startModalProps, setStartModalProps] = React.useState(null);
    // 当前操作目标记录的ID.（可多个动作公用）
    const [actionTargetId, setActionTargetId] = React.useState(null);
    // 当前操作目标记录的数据.（可多个动作公用）
    const [actionTarget, setActionTarget] = React.useState({});
    // 催办操作弹框显示与否。
    const [pressActionModalVisible, setPressActionModalVisible] = React.useState(false);
    const [progressActionModalVisible, setProgressActionModalVisible] = React.useState(false);
    const [pauseActionModalVisible, setPauseActionModalVisible] = React.useState(false);
    const [cancelNoActionModalVisible, setCancelNoActionModalVisible] = React.useState(false);
    const [cancelActionModalVisible, setCancelActionModalVisible] = React.useState(false);
    const [cancelDirectActionModalVisible, setCancelDirectActionModalVisible] = React.useState(false);
    // 转进行中弹窗
    const [turnDoingFalseModalVisible, setTurnDoingFalseModalVisible] = React.useState(false);
    const [turnDoingTrueModalVisible, setTurnDoingTrueModalVisible] = React.useState(false);
    // 转已完成弹窗
    const [turnFinishActionModalVisible, setTurnFinishActionModalVisible] = React.useState(false);
    const [sendBackActionModalVisible, setSendBackActionModalVisible] = React.useState(false);
    const [transferActionModalVisible, setTransferActionModalVisible] = React.useState(false);
    const [delayFormModalVisible, setDelayFormModalVisible] = React.useState(false);
    const [acceptanceModalVisible, setAcceptanceModalVisible] = useState(false);
    const [auditRefuseModalVisible, setAuditRefuseModalVisible] = React.useState(false);
    // 重估申请
    const [reEstimateActionModalVisible, setReEstimateActionModalVisible] = React.useState(false);
    // 重估申请的审核人
    const [reEstimateUser, setreEstimateUser] = React.useState('');

    // 估算/重估
    const [modalType, setModalType] = React.useState('');
    const [records, setRecords] = React.useState([]);
    const [assessmentModalVisible, setAssessmentModalVisible] = React.useState(false);
    // 工作量管理弹窗
    const [applyAssessmentModal, setApplyAssessmentModal] = React.useState(false);

    const ReScoreModalRef = React.useRef();
    const RatingFormModalRef = React.useRef();
    const RatingMgtModalRef = React.useRef();
    const fetchDetail = async () => {
        setLoading(true);
        const params = { id: urlQuery.id };
        const result = await getTaskInfo(params);

        if (result.code === 10000) {
            setDetailInfo(result.data);
        } else {
            message.error(result.msg);
            pageTabUtil.goBack();
            // pageTabUtil.closeTab();
        }
        setRefreshComp(refreshComp + 1);
        setLoading(false);
    };

    const handleStartOk = () => {
        fetchDetail();
    };

    const refresh = () => {
        fetchDetail();
        refreshTaskCount(dispatch);
        const { type } = urlQuery;
        const { estimationState, ...rest } = urlQuery;
        /**
         * 提交提交成功后-隐藏掉路由上面的estimationState参数
         * 由于估算和重估是根据路由上estimationState字段判断是否显示的
         * 所以提交成功后请理掉字段
         */
        if (Number(type) === PageFromType.RECKON && estimationState) {
            history.push({
                query: {
                    ...rest
                }
            });
        }
        /**
         * 工作量管理右上角按钮，提交成功后把type变为''
         */
        if (Number(type) === PageFromType.RECKON_NODEEN || Number(type) === PageFromType.RECKON_START) {
            history.push({
                query: {
                    ...urlQuery,
                    type: ''
                }
            });
        }
    };

    const openStartModal = (type, record) => {
        setStartModalProps({
            type,
            record
        });
        setStartModalVisible(true);
    };

    const ACTIONS = {
        [TaskAction.NEW]: async record => {
            const { launchAuditFlag = '', sendBackFlag = '' } = record;
            if (launchAuditFlag) {
                showTipBoxInfoModal({
                    title: '新增子任务',
                    rows: ['当前任务审核不通过，无法新增子任务', '请重新发起任务！']
                });
                return;
            }
            if (sendBackFlag) {
                showTipBoxInfoModal({
                    title: '新增子任务',
                    rows: [`当前任务已被执行人【${record.executor || ''}】退回，无法新增子任务`, '请指派给其他人执行！']
                });
                return;
            }
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    inAcceptanceFlag,
                    acceptanceEmployeeName,
                    allAuditNotPassFlag
                } = data;
                if (enable) {
                    openStartModal('new_child_task', record);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '新增子任务',
                        taskId: record.id,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        title: '新增子任务',
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (allAuditNotPassFlag) {
                    showTipBoxInfoModal({
                        title: '新增子任务',
                        rows: ['当前任务审核不通过，无法新增子任务', '请变更任务重新审核！']
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.PRESS]: async record => {
            const [flag, data] = await canPress(record.id);
            if (flag) {
                setActionTarget(data);
                setPressActionModalVisible(true);
            } else {
                const { auditNotPassFlag, sendBackFlag } = data;
                let rows;
                if (sendBackFlag) {
                    rows = [`当前任务已被执行人【${record.executor || ''}】退回，无法发起催办`, '请指派给其他人执行！'];
                } else if (auditNotPassFlag) {
                    rows = ['当前任务审核不通过，无法发起催办', '请重新发起任务！'];
                }
                showTipBoxInfoModal({
                    title: '催办',
                    rows
                });
            }
        },
        [TaskAction.PAUSE]: async record => {
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    inAcceptanceFlag,
                    acceptanceEmployeeName,
                    operateType
                } = data;
                if (enable) {
                    setPauseActionModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '暂停',
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        title: '暂停',
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.CONTINUE]: async record => {
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const { enable, inAuditFlag, auditEmployeeName, operateType } = data;
                if (enable) {
                    let taskRole = 1;
                    const { type } = urlQuery;
                    if (toNum(type) === PageFromType.EXECUTE) {
                        taskRole = 3;
                    }
                    showContinueModal({
                        taskId: record.id,
                        taskRole,
                        onOk: () => {
                            refresh();
                        }
                    });
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '继续执行',
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
            }
            message.error('操作失败！');
        },
        [TaskAction.CANCEL]: async record => {
            const { launchAuditFlag = '', sendBackFlag = '' } = record;
            if (launchAuditFlag || sendBackFlag) {
                setCancelDirectActionModalVisible(true);
                return;
            }
            const res = await getCancelInfo(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    inAcceptanceFlag,
                    acceptanceEmployeeName,
                    subTaskInProgressFlag,
                    operateType
                } = data;
                if (enable) {
                    setActionTarget(data);
                    setCancelActionModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '取消',
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        title: '取消',
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (subTaskInProgressFlag) {
                    setCancelNoActionModalVisible(true);
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.DOING]: async record => {
            const { launchAuditFlag = '', sendBackFlag = '' } = record;
            if (launchAuditFlag) {
                showTipBoxInfoModal({
                    title: '转进行中',
                    rows: ['当前任务审核不通过，无法转进行中', '请重新发起任务！']
                });
                return;
            }
            if (sendBackFlag) {
                showTipBoxInfoModal({
                    title: '转进行中',
                    rows: [`当前任务已被执行人【${record.executor || ''}】退回，无法转进行中`, '请指派给其他人执行！']
                });
                return;
            }
            const res = await getTurnDoingInfo(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    operateType,
                    frontTaskFinishFlag,
                    auditNotPassFlag
                } = data;
                if (enable) {
                    setActionTarget(data);
                    setTurnDoingTrueModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '转进行中',
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (auditNotPassFlag) {
                    showTipBoxInfoModal({
                        title: '转进行中',
                        rows: ['当前任务审核不通过，无法转进行中', '请变更任务重新审核！']
                    });
                    return;
                }
                if (!frontTaskFinishFlag) {
                    setActionTarget(data);
                    setTurnDoingFalseModalVisible(true);
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.COPY]: record => {
            openStartModal('copy_task', record);
        },
        [TaskAction.PROGRESS]: async record => {
            const res = await getProgressInfo(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    inAcceptanceFlag,
                    acceptanceEmployeeName,
                    operateType
                } = data;
                if (enable) {
                    setActionTarget(data);
                    setProgressActionModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '填写进度',
                        taskId: record.id,
                        operateType,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        title: '填写进度',
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.DONE]: async record => {
            const taskId = record.id;
            // 校验是否可以操作转已完成
            const res = await checkTurnFinish(taskId);
            const { code, data, msg } = res;
            if (code !== 10000 || !data) {
                return message.error(msg || '操作失败~~~');
            }
            const {
                enable,
                hasUnDoneSubTask,
                inAuditFlag,
                auditEmployeeName,
                operateType,
                inAcceptanceFlag,
                acceptanceEmployeeName
            } = data;
            if (!enable) {
                // 是否存在未完成的子任务
                if (hasUnDoneSubTask) {
                    return showTurnFinishExistsOnDoningSubInfoModal({ taskId });
                }
                // 处于待审核
                if (inAuditFlag) {
                    return showPressModal({
                        form,
                        title: '转已完成',
                        taskId,
                        operateType,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                }
                // 处于待验收状态
                if (inAcceptanceFlag) {
                    return showPressModal({
                        form,
                        title: '转已完成',
                        taskId,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                }
            }
            return setTurnFinishActionModalVisible(true);
        },
        [TaskAction.RESTART]: async record => {
            const res = await getRestartInfo(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    operateType,
                    parentTaskDoneFlag,
                    parentTaskName,
                    parentTaskNo
                } = data;
                if (enable) {
                    openStartModal('restart_task', record);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        taskId: record.id,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        operateType,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (parentTaskDoneFlag) {
                    showUnRestartModal({ parentTaskName, parentTaskNo });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.CHANGE]: async record => {
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const { enable, inAuditFlag, auditEmployeeName, inAcceptanceFlag, acceptanceEmployeeName } = data;
                if (enable) {
                    openStartModal('change_task', record);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        taskId: record.id,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.BACK]: async record => {
            const res = await getSendBackInfo(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const { enable, inAuditFlag, auditEmployeeName, operateType } = data;
                if (enable) {
                    setSendBackActionModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.RECHECK]: record => showReScoreModal(record, ReScoreModalRef, setLoading, form),

        [TaskAction.SCORE]: record =>
            RatingFormModalRef.current.checkScoreDimension(
                { ...record, taskScoreDetailId: urlQuery.taskScoreDetailId },
                false,
                setLoading
            ),

        [TaskAction.RESCORE]: record =>
            RatingFormModalRef.current.checkScoreDimension(
                { ...record, taskScoreDetailId: urlQuery.taskScoreDetailId },
                true,
                setLoading
            ),

        [TaskAction.ABANDON_SCORE]: record =>
            RatingFormModalRef.current.handleGiveUpRate({ ...record, taskScoreDetailId: urlQuery.taskScoreDetailId }),

        [TaskAction.SCORE_START]: () =>
            RatingMgtModalRef.current.handleLaunch([urlQuery], scoreModalTypes.LAUNCH_RATE.key),

        [TaskAction.MOVE_TO_NO_SCORE]: () =>
            RatingMgtModalRef.current.moveToNoScore([urlQuery], scoreModalTypes.MOVE_TO_NO_RATE.key),

        [TaskAction.MOVE_TO_BE_SCORE]: () =>
            RatingMgtModalRef.current.moveToBeScored([urlQuery], scoreModalTypes.MOVE_TO_WAIT.key),

        [TaskAction.TRANSFER]: async record => {
            const taskId = record.id;
            const res = await checkOperate(taskId);
            const { code, data } = res;
            if (code === 10000) {
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    operateType,
                    auditEmployeeCode,
                    acceptanceEmployeeCode
                } = data;
                if (enable) {
                    setActionTarget({ id: taskId, auditEmployeeCode, acceptanceEmployeeCode });
                    setTransferActionModalVisible(true);
                    return;
                }
                // 处于待审核
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '转派',
                        taskId,
                        operateType,
                        type: '审核',
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.DELAY]: async record => {
            // 延期
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                // 当前任务属于待审核状态/待验收时不能操作
                const {
                    enable,
                    inAuditFlag,
                    auditEmployeeName,
                    inAcceptanceFlag,
                    acceptanceEmployeeName,
                    operateType
                } = data;
                if (enable) {
                    setDelayFormModalVisible(true);
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        title: '提示',
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                if (inAcceptanceFlag) {
                    showPressModal({
                        form,
                        title: '提示',
                        taskId: record.id,
                        type: '验收',
                        employeeName: acceptanceEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }

                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.RECKON]: async record => {
            const res = await checkOperate(record.id);
            const { code, data } = res;
            if (code === 10000) {
                const { enable, inAuditFlag, auditEmployeeName, operateType } = data;
                if (enable) {
                    const result = await getreestimationemployeelist({ taskId: record.id });
                    if (result.code === 10000) {
                        if (result.data && result.data.length > 0) {
                            setreEstimateUser(result.data);
                            setReEstimateActionModalVisible(true);
                        } else {
                            message.warning('该任务暂无可重估人员');
                        }
                    } else {
                        message.error(result.msg);
                    }
                    return;
                }
                if (inAuditFlag) {
                    showPressModal({
                        form,
                        taskId: record.id,
                        type: '审核',
                        operateType,
                        employeeName: auditEmployeeName,
                        onOk: () => {
                            fetchDetail();
                        }
                    });
                    return;
                }
                return;
            }
            message.error('操作失败！');
        },
        [TaskAction.PASS]: async record => {
            const { type } = urlQuery;
            if (toNum(type) === PageFromType.ACCEPT) {
                showAcceptanceYesModal({
                    taskId: urlQuery.id,
                    onOk: () => {
                        refresh();
                    }
                });
            } else if (toNum(type) === PageFromType.AUDIT) {
                // 审核通过
                try {
                    const [pass, data] = await canAudit(record.parentTaskId, TaskAuditType.PASS);
                    if (!pass) {
                        showCantCheckInfoModal(data);
                        return;
                    }
                    showAuditPassActionModal(record, refresh);
                } catch (e) {
                    message.error(e);
                }
            }
        },
        [TaskAction.REFUSE]: async record => {
            const { type } = urlQuery;
            if (toNum(type) === PageFromType.ACCEPT) {
                setActionTargetId(urlQuery.id);
                setAcceptanceModalVisible(true);
            } else if (toNum(type) === PageFromType.AUDIT) {
                // 审核不通过
                try {
                    const [pass, data] = await canAudit(record.parentTaskId, TaskAuditType.REFUSE);
                    if (!pass) {
                        showCantCheckInfoModal(data);
                        return;
                    }
                    setActionTarget(record);
                    setAuditRefuseModalVisible(true);
                } catch (e) {
                    message.error(e);
                }
            }
        },
        [TaskAction.ESTIMATION]: async () => {
            const { taskNo, estimationState } = urlQuery;
            const res = await getEstimatedTaskList({ taskNo, estimationStateList: [1, 4] });
            if (res.code === 10000) {
                // 一般这里都会有值
                setRecords(res.data.rows.length > 0 ? res.data.rows[0] : []);
                if (Number(estimationState) === 1) {
                    setModalType('estimate');
                }
                if (Number(estimationState) === 4) {
                    setModalType('reCalculate');
                }
                setAssessmentModalVisible(true);
            } else {
                message.error(res.msg);
            }
        },
        [TaskAction.RESUME_ESTIMATION]: async () => {
            const { taskNo, estimationState } = urlQuery;
            const res = await getEstimatedTaskList({ taskNo, estimationStateList: [1, 4] });
            if (res.code === 10000) {
                // 一般这里都会有值
                setRecords(res.data.rows.length > 0 ? res.data.rows[0] : []);
                if (Number(estimationState) === 1) {
                    setModalType('estimate');
                }
                if (Number(estimationState) === 4) {
                    setModalType('reCalculate');
                }
                setAssessmentModalVisible(true);
            } else {
                message.error(res.msg);
            }
        },
        [TaskAction.LAUNCH_ESTIMATION]: async () => {
            const { taskNo } = urlQuery;
            const res = await getEstimationlaunch({ taskNo });
            if (res.code === 10000) {
                setRecords(res.data.rows.length > 0 ? [res.data.rows[0]] : []);
                setModalType('apply');
                setApplyAssessmentModal(true);
            } else {
                message.error(res.msg);
            }
        },
        [TaskAction.MOVE_NONEED]: async () => {
            const { taskNo } = urlQuery;
            const res = await getEstimationlaunch({ taskNo });
            if (res.code === 10000) {
                setRecords(res.data.rows.length > 0 ? [res.data.rows[0]] : []);
                setModalType('noNeed');
                setApplyAssessmentModal(true);
            } else {
                message.error(res.msg);
            }
        },
        [TaskAction.MOVE_STARTESTIMATE]: async () => {
            const { taskNo } = urlQuery;
            const res = await getEstimationnotrequired({ taskNo });
            if (res.code === 10000) {
                // 一般这里都会有值
                setRecords(res.data.rows.length > 0 ? [res.data.rows[0]] : []);
                setModalType('goback');
                setApplyAssessmentModal(true);
            } else {
                message.error(res.msg);
            }
        }
    };

    const handleActionClick = item => async () => {
        if ([PageFromType.SCORE].includes(toNum(urlQuery.type))) {
            return ACTIONS[item](detailInfo);
        }
        if (loading) return null;
        setLoading(true);
        try {
            const record = detailInfo;
            setActionTarget(record);
            setActionTargetId(record.id);
            if (ACTIONS[item]) {
                await ACTIONS[item](record);
            }
        } catch (e) {
            console.error(e);
        } finally {
            setLoading(false);
        }
        return null;
    };

    const ACTION_START = {
        [TaskStatus.FINISH]: [TaskAction.COPY],
        [TaskStatus.CANCEL]: [TaskAction.COPY],
        [TaskStatus.READY]: [
            TaskAction.CHANGE,
            TaskAction.PRESS,
            TaskAction.NEW,
            TaskAction.CANCEL,
            TaskAction.DOING,
            TaskAction.COPY
        ],
        [TaskStatus.ONGOING]: [
            TaskAction.CHANGE,
            TaskAction.PRESS,
            TaskAction.NEW,
            TaskAction.PAUSE,
            TaskAction.CANCEL,
            TaskAction.COPY,
            TaskAction.PROGRESS,
            TaskAction.DONE
        ],
        [TaskStatus.PAUSE]: [TaskAction.CHANGE, TaskAction.CANCEL, TaskAction.NEW, TaskAction.CONTINUE, TaskAction.COPY]
    };

    const ACTION_EXECUTE = {
        // [TaskStatus.FINISH]: [TaskAction.RECHECK, TaskAction.COPY, TaskAction.RECKON],
        [TaskStatus.FINISH]: [TaskAction.COPY],
        [TaskStatus.CANCEL]: [TaskAction.COPY],
        [TaskStatus.READY]: [
            TaskAction.DOING,
            TaskAction.BACK,
            TaskAction.TRANSFER,
            TaskAction.NEW,
            TaskAction.DELAY,
            TaskAction.CANCEL,
            TaskAction.COPY
            // TaskAction.RECKON
        ],
        [TaskStatus.ONGOING]: [
            TaskAction.DONE,
            TaskAction.PROGRESS,
            TaskAction.PRESS,
            TaskAction.DELAY,
            TaskAction.PAUSE,
            TaskAction.CANCEL,
            TaskAction.NEW,
            TaskAction.COPY
            // TaskAction.RECKON
        ],
        [TaskStatus.PAUSE]: [TaskAction.CONTINUE, TaskAction.CANCEL, TaskAction.NEW, TaskAction.COPY]
    };

    const getActionList = (type, status) => {
        let tempList = [];
        if (type === PageFromType.START) {
            tempList = ACTION_START[status] || [];
            if (detailInfo && detailInfo.launchAuditFlag) {
                tempList[0] = TaskAction.RESTART;
            }
            if (detailInfo && detailInfo.sendBackFlag) {
                tempList[0] = TaskAction.TRANSFER;
            }
        } else if (type === PageFromType.EXECUTE) {
            tempList = ACTION_EXECUTE[status] || [];
        } else if (type === PageFromType.PARTICIPATE) {
            const { taskStatus } = detailInfo;
            if (
                taskStatus === TaskStatus.ONGOING ||
                taskStatus === TaskStatus.READY ||
                taskStatus === TaskStatus.PAUSE
            ) {
                tempList = [TaskAction.NEW];
            }
        } else if (type === PageFromType.AUDIT) {
            const { taskAuditStatus } = detailInfo;
            if (taskAuditStatus === 0 || taskAuditStatus === 3) {
                tempList = [TaskAction.PASS, TaskAction.REFUSE];
            }
        } else if (type === PageFromType.ACCEPT) {
            const { taskAcceptStatus } = detailInfo;
            if (taskAcceptStatus === 0 || taskAcceptStatus === 3) {
                tempList = [TaskAction.PASS, TaskAction.REFUSE];
            }
        } else if (type === PageFromType.RECKON) {
            const { estimationState } = urlQuery;
            if (Number(estimationState) === 1) {
                tempList = [TaskAction.ESTIMATION];
            }
            if (Number(estimationState) === 4) {
                tempList = [TaskAction.RESUME_ESTIMATION];
            }
        } else if (type === PageFromType.RECKON_START) {
            tempList = [TaskAction.LAUNCH_ESTIMATION, TaskAction.MOVE_NONEED];
        } else if (type === PageFromType.RECKON_NODEEN) {
            tempList = [TaskAction.MOVE_STARTESTIMATE];
        } else if (type === PageFromType.SCORE) {
            // console.log(detailInfo);
            const { scoreState } = urlQuery;
            if (scoreState === 0) {
                tempList = [TaskAction.SCORE, TaskAction.ABANDON_SCORE];
            }
            if (scoreState === 3) {
                tempList = [TaskAction.RESCORE, TaskAction.ABANDON_SCORE];
            }
        } else if (type === PageFromType.SCORE_START) {
            tempList = [TaskAction.SCORE_START, TaskAction.MOVE_TO_NO_SCORE];
        } else if (type === PageFromType.NO_SCORE) {
            tempList = [TaskAction.MOVE_TO_BE_SCORE];
        }
        if (detailInfo && detailInfo.cycleTaskFlag) {
            return tempList.filter(item => item !== TaskAction.NEW);
        }
        if (detailInfo && detailInfo.processTaskEmployeeCode === user.employeeCode) {
            return tempList.filter(item => item !== TaskAction.PRESS);
        }
        return tempList;
    };

    const getActionMenu = task => {
        const { type } = urlQuery;
        const { taskStatus = '' } = task;
        const arr = getActionList(toNum(type), taskStatus);
        let list = [];
        if (arr.length > 0) {
            list = arr.map(item => ({
                text: ActionObj[item],
                value: toNum(item)
            }));
        }
        const menu = menuList => {
            if (menuList && menuList.length > 0) {
                return (
                    <Menu>
                        {menuList.map(item => (
                            <Menu.Item key={item.value} onClick={handleActionClick(item.value)}>
                                {item.text}
                            </Menu.Item>
                        ))}
                    </Menu>
                );
            }
            return null;
        };
        return (
            <>
                {list.slice(0, 3).map(item => (
                    <Button
                        type="primary"
                        ghost
                        style={{ marginLeft: 8 }}
                        onClick={handleActionClick(item.value)}
                        key={item.value}
                    >
                        {item.text}
                    </Button>
                ))}
                {list.length > 3 && (
                    <Dropdown
                        overlay={menu(list.slice(3))}
                        trigger={['click']}
                        getPopupContainer={trigger => trigger.parentNode}
                    >
                        <Button type="primary" ghost style={{ marginLeft: 8 }}>
                            更多 <Icon type="down" />
                        </Button>
                    </Dropdown>
                )}
            </>
        );
    };

    const detailCardTitle = (
        <span>
            <span>任务详情</span>
            {detailInfo.taskNo ? (
                <Tag color="orange" style={{ marginLeft: '8px' }}>
                    {detailInfo.taskNo}
                </Tag>
            ) : null}
        </span>
    );

    const renderProgress = (taskStatus, taskProgress = '0') => {
        let format = {};
        let colorProgress = '#5AD8A6';
        if (toNum(taskProgress) >= 100) {
            format = {
                format: () => '100%'
            };
        }
        if (taskStatus === TaskStatus.FINISH || taskStatus === TaskStatus.CANCEL) {
            colorProgress = '#999999';
        } else if (taskStatus === TaskStatus.PAUSE) {
            colorProgress = '#FFA784';
        }
        return (
            <Progress
                className={styles.taskProgress}
                percent={Number(taskProgress)}
                strokeColor={colorProgress}
                size="small"
                {...format}
            />
        );
    };

    // 切换tab更改key值刷新列表
    useEffect(() => {
        fetchDetail();
        setShowTab(urlQuery.activeKey || 'detailMsg');
    }, [urlQuery]);

    const getList = list => (
        <div>
            {list &&
                list.map((item, index) => {
                    if (index === 0) {
                        return (
                            <div
                                key={item.taskName}
                                title={item.taskName}
                                style={{
                                    // color: '#FFA22D',
                                    wordBreak: 'break-word',
                                    overflow: 'hidden',
                                    whiteSpace: 'nowrap',
                                    textOverflow: 'ellipsis'
                                    // cursor: 'pointer'
                                }}
                                // onClick={() => {
                                //     history.push({
                                //         pathname: '/work/task/taskdetail',
                                //         query: {
                                //             id: item.taskId,
                                //             activeKey: 'detailMsg'
                                //         }
                                //     });
                                // }}
                            >
                                {item.taskName}
                            </div>
                        );
                    }
                    return null;
                })}
        </div>
    );
    const getTime = time => {
        if (time.indexOf('00:00:00') === -1 && time.indexOf('23:59:59') === -1) {
            return moment(time).format('YYYY-MM-DD HH:mm');
        }
        return moment(time).format('YYYY-MM-DD');
    };
    // const remind = () => {
    //     if (detailInfo.remindDuration) {
    //         return TimeFormatMin(detailInfo.remindDuration);
    //     }
    //     if (detailInfo.remindDate) {
    //         return getTime(detailInfo.remindDate);
    //     }
    //     return '';
    // };
    const sbTime = (time, hour = 8) => {
        if (time) {
            return `${TimeFormatHour(time)} ${time ? '(' : ''}${TimeFormat(time, hour)}${time ? ')' : ''}`;
        }
        return '0小时(0天0小时0分钟)';
    };
    const sbTimeTwo = time => {
        if (time) {
            return `${TimeFormatHour(time)} ${time ? '(' : ''}${TimeFormat(time)}${time ? ')' : ''}`;
        }
        return '';
    };

    const taskDetails = [
        // {
        //     key: '关联产品:',
        //     value: (
        //         // <a title={detailInfo.relateProductName} style={{ wordBreak: 'break-word' }}>
        //         //     {detailInfo.relateProductName}
        //         // </a>
        //         <div
        //             title={detailInfo.relateProductName}
        //             style={{
        //                 color: '#FFA22D',
        //                 wordBreak: 'break-word',
        //                 overflow: 'hidden',
        //                 whiteSpace: 'nowrap',
        //                 textOverflow: 'ellipsis',
        //                 cursor: 'pointer'
        //             }}
        //         >
        //             {detailInfo.relateProductName}
        //         </div>
        //     )
        // },
        // {
        //     key: '关联项目:',
        //     value: (
        //         // <a title={detailInfo.relateProjectName} style={{ wordBreak: 'break-word' }}>
        //         //     {detailInfo.relateProjectName}
        //         // </a>
        //         <div
        //             title={detailInfo.relateProjectName}
        //             style={{
        //                 color: '#FFA22D',
        //                 wordBreak: 'break-word',
        //                 overflow: 'hidden',
        //                 whiteSpace: 'nowrap',
        //                 textOverflow: 'ellipsis',
        //                 cursor: 'pointer'
        //             }}
        //         >
        //             {detailInfo.relateProjectName}
        //         </div>
        //     )
        // },
        {
            key: '前置任务:',
            value: getList(detailInfo.frontTaskList)
        },
        {
            key: '一级任务:',
            hide: detailInfo.firstLevelTaskEnableChildrenQueryFlag && detailInfo.firstLevelTaskId !== detailInfo.id,
            value: (
                <div
                    title={detailInfo.firstLevelTaskName}
                    style={{
                        wordBreak: 'break-word',
                        overflow: 'hidden',
                        whiteSpace: 'nowrap',
                        textOverflow: 'ellipsis'
                    }}
                >
                    {detailInfo.firstLevelTaskName}
                </div>
            )
        },
        {
            key: '一级任务:',
            hide: !(detailInfo.firstLevelTaskEnableChildrenQueryFlag && detailInfo.firstLevelTaskId !== detailInfo.id),
            value: (
                <div
                    title={detailInfo.firstLevelTaskName}
                    style={{
                        color: '#FFA22D',
                        wordBreak: 'break-word',
                        overflow: 'hidden',
                        whiteSpace: 'nowrap',
                        textOverflow: 'ellipsis',
                        cursor: 'pointer'
                    }}
                    onClick={() => {
                        history.push({
                            pathname: '/work/task/taskdetail',
                            query: {
                                id: detailInfo.firstLevelTaskId,
                                activeKey: 'detailMsg'
                            }
                        });
                    }}
                >
                    {detailInfo.firstLevelTaskName}
                </div>
            )
        },
        // {
        //     key: '一级任务查阅:',
        //     value: `${
        //         detailInfo && detailInfo.firstLevelTaskEnableChildrenQueryFlag === 1
        //             ? '允许被下级所有子任务查阅'
        //             : '不允许被下级所有子任务查阅'
        //     }`
        // },
        {
            key: '上一级任务:',
            value: (
                <div
                    title={detailInfo.parentTaskName}
                    style={{
                        // color: '#FFA22D',
                        wordBreak: 'break-word',
                        overflow: 'hidden',
                        whiteSpace: 'nowrap',
                        textOverflow: 'ellipsis'
                        // cursor: 'pointer'
                    }}
                    // onClick={() => {
                    //     history.push({
                    //         pathname: '/work/task/taskdetail',
                    //         query: {
                    //             id: detailInfo.parentTaskId,
                    //             activeKey: 'detailMsg'
                    //         }
                    //     });
                    // }}
                >
                    {detailInfo.parentTaskName}
                </div>
                // <span
                //     title={detailInfo.parentTaskName}
                //     style={{ color: '#ffa808', cursor: 'pointer', wordBreak: 'break-word' }}
                //     onClick={() => {
                //         history.push({
                //             pathname: '/work/task/taskdetail',
                //             query: {
                //                 id: detailInfo.parentTaskId,
                //                 activeKey: 'detailMsg'
                //             }
                //         });
                //     }}
                // >
                //     {detailInfo.parentTaskName}
                // </span>
            )
        },
        {
            key: '关联任务:',
            value: getList(detailInfo.relateTaskList)
        },
        {
            key: '任务来源:',
            value: detailInfo.sourceName
        },
        {
            key: '任务状态:',
            value: getTaskStatus(detailInfo.taskStatus)
        },
        {
            key: '优先级:',
            value: getTaskPriority(detailInfo.taskPriority)
        },
        {
            key: '开始执行情况:',
            value: (
                <span style={{ color: detailInfo.startExecuteSituation === 3 ? '#F5222D' : '#787878' }}>
                    {getTaskSituation(detailInfo.startExecuteSituation)}
                </span>
            )
        },
        {
            key: '完成执行情况:',
            value: (
                <span style={{ color: detailInfo.endExecuteSituation === 3 ? '#F5222D' : '#787878' }}>
                    {getTaskSituation(detailInfo.endExecuteSituation)}
                </span>
            )
        },
        {
            key: '当前进度:',
            value: renderProgress(detailInfo.taskStatus, detailInfo.taskProgress)
        },
        {
            key: '被催办次数:',
            value: detailInfo.urgeCount || 0
        },
        {
            key: '发起人:',
            value: detailInfo.initiator
        },
        {
            key: '执行人:',
            value: detailInfo.executor
        },
        {
            key: '验收人:',
            value: detailInfo.acceptor
        },
        {
            key: '审核人:',
            value: detailInfo.auditor
        },
        {
            key: ' 参与人:',
            value: detailInfo.participant
        },
        // {
        //     key: '抄送给:',
        //     value: detailInfo.auditor
        // },
        {
            key: '评分发起人:',
            value: !!detailInfo.scoreInitiator && detailInfo.scoreInitiator.split('（')[0]
        },
        {
            key: '  估算发起人:',
            value: detailInfo.estimateInitiator
        }
    ];
    const timeDetails = [
        {
            key: '发起时间:',
            value: detailInfo.launchTime && getTime(detailInfo.launchTime)
        },
        {
            key: '工作量:',
            value: detailInfo.taskWorkPoint
        },
        {
            key: '开始时间:',
            value: detailInfo.planStartTime && getTime(detailInfo.planStartTime)
        },
        {
            key: '实际开始时间:',
            value: detailInfo.actualStartTime && getTime(detailInfo.actualStartTime)
        },
        {
            key: '截止时间:',
            value: detailInfo.planEndTime && getTime(detailInfo.planEndTime)
        },
        {
            key: '实际完成时间:',
            value: detailInfo.actualEndTime && getTime(detailInfo.actualEndTime)
        },
        {
            key: '逾期时间:',
            value: detailInfo.actualEndTime && detailInfo.planEndTime ? delayTimeFormat(detailInfo.overdueWorkTime) : ''
        },
        {
            key: '预估工时:',
            value: sbTimeTwo(detailInfo.estimateWorkDuration)
        },
        {
            key: '实际工时:',
            value: sbTimeTwo(detailInfo.actualWorkDuration)
        },
        {
            key: '逾期工时:',
            value:
                detailInfo.estimateWorkDuration && detailInfo.actualWorkDuration
                    ? sbTime(detailInfo.overdueWorkDuration, 8)
                    : ''
        }
    ];
    const otherDetails = [
        {
            key: '提前提醒:',
            value: detailInfo.remindMsg
        },
        {
            key: '通用类型:',
            value: getTaskDuration(detailInfo.generalType)
        },
        {
            key: '通知方式:',
            value: detailInfo.taskNoticeWay
        },
        {
            key: '是否周期任务:',
            value: `${getTaskFlag(detailInfo.cycleTaskFlag)} ${
                detailInfo.cycleTaskFlag && detailInfo.cycleTaskFlag === 1 ? detailInfo.cycleTaskInfo : ''
            }`
        },
        {
            key: '是否个人隐私:',
            value: getTaskFlag(detailInfo.personalPrivacyFlag)
        }
    ];

    const cardStyle = {
        height: '100%',
        borderBottomRightRadius: '0',
        borderTopLeftRadius: '0',
        borderTopRightRadius: '0'
    };

    return (
        <PageHeaderWrapper>
            <Spin spinning={loading}>
                <Card
                    bordered={false}
                    extra={getActionMenu(detailInfo)}
                    title={detailCardTitle}
                    style={{
                        borderRadius: '0',
                        borderBottom: '1px solid #EDEDED',
                        paddingBottom: '10px'
                    }}
                    headStyle={{ borderBottom: 'none' }}
                >
                    <Row span={24} gutter={16}>
                        <Col span={22} className={styles.taskName}>
                            {detailInfo.taskName}
                        </Col>
                    </Row>
                </Card>
                <Row
                    type="flex"
                    span={24}
                    gutter={16}
                    style={{
                        flexWrap: 'nowrap',
                        alignItems: 'stretch',
                        background: '#fff',
                        marginLeft: '0',
                        marginRight: '0',
                        paddingBottom: showTab === 'scoreRec' || showTab === 'assessmentRec' ? 0 : '36px'
                    }}
                >
                    <Col
                        style={{
                            flex: 1,
                            overflow: 'hidden',
                            paddingRight: '0',
                            paddingLeft: 0,
                            borderRight: '1px solid #EDEDED'
                        }}
                    >
                        <Card className={styles.contentWrap} bordered={false} style={cardStyle}>
                            <Tabs activeKey={showTab} onChange={key => setShowTab(key)} className={styles.myDetailTab}>
                                <TabPane tab="详细信息" key="detailMsg">
                                    <DetailInfo
                                        detailInfo={detailInfo}
                                        searchId={urlQuery.id}
                                        activeKey={showTab}
                                        refreshComp={refreshComp}
                                    ></DetailInfo>
                                </TabPane>
                                <TabPane tab="任务环节" key="taskLink">
                                    <TaskLink
                                        location={location}
                                        refreshComp={refreshComp}
                                        activeKey={showTab}
                                        searchId={urlQuery.id}
                                    ></TaskLink>
                                </TabPane>
                                <TabPane tab="进度记录" key="executionCycle">
                                    <ExecutionCycle
                                        location={location}
                                        activeKey={showTab}
                                        searchId={urlQuery.id}
                                        refreshComp={refreshComp}
                                    ></ExecutionCycle>
                                </TabPane>
                                <TabPane tab="子任务" key="sonTask">
                                    <SubTask
                                        location={location}
                                        activeKey={showTab}
                                        refreshComp={refreshComp}
                                    ></SubTask>
                                </TabPane>
                                <TabPane tab="变更记录" key="changeRec">
                                    <ChangeRec
                                        location={location}
                                        activeKey={showTab}
                                        refreshComp={refreshComp}
                                    ></ChangeRec>
                                </TabPane>
                                <TabPane tab="评分记录" key="scoreRec">
                                    <ScoreRec
                                        location={location}
                                        activeKey={showTab}
                                        id={urlQuery.id}
                                        urlQuery={urlQuery}
                                        refreshComp={refreshComp}
                                    ></ScoreRec>
                                </TabPane>
                                <TabPane tab="估算记录" key="assessmentRec">
                                    <EstimateRec
                                        location={location}
                                        activeKey={showTab}
                                        urlQuery={urlQuery}
                                        refreshComp={refreshComp}
                                    ></EstimateRec>
                                </TabPane>
                                <TabPane tab="操作记录" key="operationRec">
                                    <OperationRec
                                        location={location}
                                        activeKey={showTab}
                                        refreshComp={refreshComp}
                                    ></OperationRec>
                                </TabPane>
                            </Tabs>
                        </Card>
                    </Col>
                    <Col style={{ width: 350, paddingLeft: 0, paddingRight: 0 }} className={styles.detailCard}>
                        <TaskDetailBox
                            title="基本信息"
                            dataSource={taskDetails.filter(item => !item.hide)}
                            style={{
                                borderBottomRightRadius: '0',
                                borderBottomLeftRadius: '0',
                                borderTopLeftRadius: '0'
                            }}
                            headStyle={{ borderBottom: 'none', fontSize: '14px', color: '#787878' }}
                        />
                        <TaskDetailBox
                            title="时间信息"
                            dataSource={timeDetails}
                            style={{
                                borderBottomRightRadius: '0',
                                borderBottomLeftRadius: '0',
                                borderTopLeftRadius: '0'
                            }}
                            headStyle={{ borderBottom: 'none', fontSize: '14px', color: '#787878' }}
                        />
                        <TaskDetailBox
                            title="其他信息"
                            dataSource={otherDetails}
                            style={{
                                borderBottomRightRadius: '0',
                                borderBottomLeftRadius: '0',
                                borderTopLeftRadius: '0'
                            }}
                            headStyle={{ borderBottom: 'none', fontSize: '14px', color: '#787878' }}
                        />
                    </Col>
                </Row>
                <RevalAplModal visible={visible} setVisible={setVisible}></RevalAplModal>
                <StartTaskModal
                    visible={startModalVisible}
                    setVisible={setStartModalVisible}
                    {...startModalProps}
                    onOk={handleStartOk}
                />
                <TransferActionModal
                    taskRecord={actionTarget}
                    onOk={() => pageTabUtil.closeTab()}
                    visible={transferActionModalVisible}
                    setVisible={setTransferActionModalVisible}
                />
                {delayFormModalVisible && (
                    <DelayFormModal
                        taskRecord={actionTarget}
                        onOk={refresh}
                        visible={delayFormModalVisible}
                        setVisible={setDelayFormModalVisible}
                    />
                )}
                {/* 催办弹窗。destoryOnClose不好用 */}
                {pressActionModalVisible && (
                    <PressActionModal
                        taskId={actionTargetId}
                        taskRecord={actionTarget}
                        visible={pressActionModalVisible}
                        setVisible={setPressActionModalVisible}
                        onOk={refresh}
                    />
                )}
                {/* 填写进度弹窗 */}
                {progressActionModalVisible && (
                    <ProgressActionModal
                        taskId={actionTargetId}
                        taskRecord={actionTarget}
                        visible={progressActionModalVisible}
                        setVisible={setProgressActionModalVisible}
                        onOk={refresh}
                    />
                )}
                <PauseActionModal
                    taskId={actionTargetId}
                    visible={pauseActionModalVisible}
                    setVisible={setPauseActionModalVisible}
                    onOk={refresh}
                />
                <CancelNoActionModal
                    taskId={actionTargetId}
                    visible={cancelNoActionModalVisible}
                    setVisible={setCancelNoActionModalVisible}
                />
                <CancelActionModal
                    taskId={actionTargetId}
                    taskRecord={actionTarget}
                    visible={cancelActionModalVisible}
                    setVisible={setCancelActionModalVisible}
                    onOk={refresh}
                />
                <CancelDirectActionModal
                    taskId={actionTargetId}
                    visible={cancelDirectActionModalVisible}
                    setVisible={setCancelDirectActionModalVisible}
                    onOk={refresh}
                />
                {/* 转进行中弹窗-前置没完成不让转 */}
                <TurnDoingFalseModal
                    taskId={actionTargetId}
                    taskRecord={actionTarget}
                    visible={turnDoingFalseModalVisible}
                    setVisible={setTurnDoingFalseModalVisible}
                ></TurnDoingFalseModal>
                {/* 转进行中弹窗-可以转 */}
                <TurnDoingTrueModal
                    taskId={actionTargetId}
                    taskRecord={actionTarget}
                    visible={turnDoingTrueModalVisible}
                    setVisible={setTurnDoingTrueModalVisible}
                    onOk={refresh}
                ></TurnDoingTrueModal>
                {/* 转已完成弹窗 */}
                {turnFinishActionModalVisible && (
                    <TurnFinishActionModal
                        taskId={actionTargetId}
                        visible={turnFinishActionModalVisible}
                        setVisible={setTurnFinishActionModalVisible}
                        onOk={refresh}
                    />
                )}
                {/* 退回 */}
                <SendBackActionModal
                    taskId={actionTargetId}
                    visible={sendBackActionModalVisible}
                    setVisible={setSendBackActionModalVisible}
                    onOk={() => {
                        pageTabUtil.closeTab();
                    }}
                />
                {/* 验收通过 */}
                <AcceptanceActionModal
                    taskId={actionTargetId}
                    visible={acceptanceModalVisible}
                    setVisible={setAcceptanceModalVisible}
                    onOk={refresh}
                />
                {auditRefuseModalVisible && (
                    <AuditRefuseActionModal
                        onOk={refresh}
                        visible={auditRefuseModalVisible}
                        taskRecord={actionTarget}
                        setVisible={setAuditRefuseModalVisible}
                    />
                )}
                {/* 重估 */}
                <ReEstimateActionModal
                    taskId={actionTargetId}
                    reEstimateUser={reEstimateUser}
                    visible={reEstimateActionModalVisible}
                    setVisible={setReEstimateActionModalVisible}
                    onOk={refresh}
                />
                {/* 重评申请 */}
                <ReRateApplyModal ReScoreModalRef={ReScoreModalRef} setActionLoading={setLoading} />
                {/* 评分和重评 */}
                <RatingFormModal
                    RatingFormModalRef={RatingFormModalRef}
                    onSuccess={() => {
                        history.push({ query: { ...urlQuery, type: '' } });
                    }}
                />
                {/* 发起评分、移入无需评分、移回待发起 */}
                <RatingMgtModal
                    RatingMgtModalRef={RatingMgtModalRef}
                    onSuccess={mType => {
                        let newPageType;
                        if (mType === scoreModalTypes.LAUNCH_RATE.key || mType === scoreModalTypes.GIVE_UP_RATE.key) {
                            newPageType = ''; // 去掉按钮
                        } else if (mType === scoreModalTypes.MOVE_TO_NO_RATE.key) {
                            newPageType = PageFromType.NO_SCORE; // 显示移回待发起
                        } else if (mType === scoreModalTypes.MOVE_TO_WAIT.key) {
                            newPageType = PageFromType.SCORE_START; // 显示发起评分和移入无需评分
                        }
                        history.push({ query: { ...urlQuery, type: newPageType } });
                    }}
                />
                {/* 估算/重估 */}
                <AssessmentModal
                    visible={assessmentModalVisible}
                    setVisible={setAssessmentModalVisible}
                    list={records}
                    onOk={refresh}
                    modalType={modalType}
                />
                {/* 发起估算/移入无需估算/移回待发起 */}
                <ApplyAssessmentModal
                    visible={applyAssessmentModal}
                    setVisible={setApplyAssessmentModal}
                    onOk={refresh}
                    modalTypes={modalType}
                    curList={records}
                    clickType="single"
                />
            </Spin>
        </PageHeaderWrapper>
    );
};

export default connect(({ user }) => ({ user: user.currentUser }))(Form.create()(MyExecuteDetail));
